<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改仪器信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-information-edit" th:object="${tmdDeviceInformation}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">仪器名称 XXX仪器：</label>
                <div class="col-sm-8">
                    <input name="deviceName" th:field="*{deviceName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所属部门id 部门id：</label>
                <div class="col-sm-8">
                    <input name="deptId" th:field="*{deptId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建人 创建人：</label>
                <div class="col-sm-8">
                    <input name="createPerson" th:field="*{createPerson}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主要技术指标 主要技术指标：</label>
                <div class="col-sm-8">
                    <input name="mainAim" th:field="*{mainAim}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">鉴定有效期 有效天数：</label>
                <div class="col-sm-8">
                    <input name="valid" th:field="*{valid}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">存放位置 写清楚具体位置即可，A号写字楼301的抽屉：</label>
                <div class="col-sm-8">
                    <input name="savePosition" th:field="*{savePosition}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">附件 附件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="file" th:field="*{file}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="file" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注 备注：</label>
                <div class="col-sm-8">
                    <textarea name="text" class="form-control">[[*{text}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "device/information";
        $("#form-information-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-information-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>